package com.fuego.creditsystemcommodity.controller;

import com.fuego.creditsystemcommodity.service.IActivityInfoService;
import com.fuego.creditsystemcommodity.service.IActivityService;
import jakarta.annotation.Resource;
import org.example.dto.Result;
import org.example.entity.Activity;
import org.example.entity.ActivityInfo;
import org.springframework.web.bind.annotation.*;




@RestController
@RequestMapping("/activity")
public class ActivityController {

    @Resource
    private IActivityService activityService;
    @Resource
    private IActivityInfoService activityInfoService;

    @PostMapping
    public Result addActivity(@RequestBody Activity activity) {
        activityService.save(activity);
        return Result.ok(activity.getId());
    }


    @PostMapping("activityInfo")
    public Result addActivityInfo(@RequestBody ActivityInfo activityInfo) {
        activityService.addActivityInfo(activityInfo);
        return Result.ok(activityInfo.getActivityId());
    }


    @GetMapping("/listOfOrganizer/{organizerId}")
    public Result queryActivityOfOrganizer(@PathVariable("organizerId") Long organizerId) {
        return activityService.queryActivityOfOrganizer(organizerId);
    }

    @GetMapping("/list/allActivity")
    public Result queryAllActivity() {
        return activityService.queryAllActivity();
    }

    @GetMapping("/activity/{activityId}")
    public Result queryActivityById(@PathVariable("activityId") Long activityId) {

        return activityService.queryActivityById(activityId);
    }

    @GetMapping("/activityInfo/{activityId}")
    public Result queryActivityInfoById(@PathVariable("activityId") Long activityId) {

        return activityInfoService.queryActivityInfoById(activityId);
    }
}

